package org.tls.ylt.user;

import org.apache.commons.mail.Email;
import org.apache.commons.mail.SimpleEmail;

public class Testa {
    public static void main(String[] args) {
        /*String fromEmail = emailConfig.getFromEmail();
        String pwd = emailConfig.getPwd();*/
        for (int j = 0; j < 100; j++) {
            System.out.println("_____________" + j + "_________");
            String fromEmail = "1450969456@qq.com";
            String pwd = "xbtisecanqglidjg";
            System.out.println(fromEmail);
            System.out.println(pwd);
            Email email = new SimpleEmail();
            try {
                //邮箱的SMTP服务器，一般126邮箱的是smtp.126.com，qq邮箱为smtp.qq.com
                email.setHostName("smtp.qq.com");
                email.setCharset("utf-8");
                //收件人
                email.addTo("1604784714@qq.com");
                //发件人,用户名可随便填写
                email.setFrom("1450969456@qq.com", "ylt");
                //你的邮箱地址和你的stmp授权码
                email.setAuthentication(fromEmail, pwd);
                //email.addCc("18642967872@163.com");//抄送方
                email.setSubject("广发信用卡身份验证");
                String[] letters = new String[]{
                        "q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "a", "s", "d", "f", "g", "h", "j", "k", "l", "z", "x", "c", "v", "b", "n", "m",
                        "A", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "A", "S", "D", "F", "G", "H", "J", "K", "L", "Z", "X", "C", "V", "B", "N", "M",
                        "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"};
                StringBuilder sb = new StringBuilder();
                for (int i = 0; i < 6; i++) {
                    sb = sb.append(letters[(int) Math.floor(Math.random() * letters.length)]);
                }
                email.setMsg("你好,本次操作验证码为：" + sb.toString() + "，有效时间3分钟");
                email.send();
                System.out.println("发送成功");
            } catch (Exception e) {
                e.printStackTrace();
                System.out.println("验证码发送失败！");
            }
        }
    }
}
